package com.dawn.module.cms.dal.mysql.department;

import java.util.*;

import com.dawn.framework.common.pojo.PageResult;
import com.dawn.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.dawn.framework.mybatis.core.mapper.BaseMapperX;
import com.dawn.module.cms.dal.dataobject.department.DepartmentDO;
import com.dawn.module.cms.dal.dataobject.doctor.DoctorDO;
import org.apache.ibatis.annotations.Mapper;
import com.dawn.module.cms.controller.admin.department.vo.*;

/**
 * 科室信息 Mapper
 *
 * @author root
 */
@Mapper
public interface DepartmentMapper extends BaseMapperX<DepartmentDO> {

    default PageResult<DepartmentDO> selectPage(DepartmentPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DepartmentDO>()
                .likeIfPresent(DepartmentDO::getName, reqVO.getName())
                .likeIfPresent(DepartmentDO::getNickname, reqVO.getNickname())
                .eqIfPresent(DepartmentDO::getCoverImg, reqVO.getCoverImg())
                .eqIfPresent(DepartmentDO::getPhone, reqVO.getPhone())
                .eqIfPresent(DepartmentDO::getWorkRange, reqVO.getWorkRange())
                .eqIfPresent(DepartmentDO::getTags, reqVO.getTags())
                .eqIfPresent(DepartmentDO::getAddress, reqVO.getAddress())
                .likeIfPresent(DepartmentDO::getOrgName, reqVO.getOrgName())
                .eqIfPresent(DepartmentDO::getHisDeptCode, reqVO.getHisDeptCode())
                .likeIfPresent(DepartmentDO::getHisDeptName, reqVO.getHisDeptName())
                .eqIfPresent(DepartmentDO::getLinkUrl, reqVO.getLinkUrl())
                .eqIfPresent(DepartmentDO::getTips, reqVO.getTips())
                .eqIfPresent(DepartmentDO::getNotice, reqVO.getNotice())
                .eqIfPresent(DepartmentDO::getDescription, reqVO.getDescription())
                .eqIfPresent(DepartmentDO::getContent, reqVO.getContent())
                .eqIfPresent(DepartmentDO::getContentFormat, reqVO.getContentFormat())
                .eqIfPresent(DepartmentDO::getRemark, reqVO.getRemark())
                .eqIfPresent(DepartmentDO::getPictures, reqVO.getPictures())
                .eqIfPresent(DepartmentDO::getFiles, reqVO.getFiles())
                .eqIfPresent(DepartmentDO::getViews, reqVO.getViews())
                .eqIfPresent(DepartmentDO::getTopping, reqVO.getTopping())
                .eqIfPresent(DepartmentDO::getRecommend, reqVO.getRecommend())
                .betweenIfPresent(DepartmentDO::getPublishTime, reqVO.getPublishTime())
                .eqIfPresent(DepartmentDO::getPublish, reqVO.getPublish())
                .eqIfPresent(DepartmentDO::getSort, reqVO.getSort())
                .eqIfPresent(DepartmentDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(DepartmentDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DepartmentDO::getSort).orderByDesc(DepartmentDO::getUpdateTime).orderByDesc(DepartmentDO::getId));
    }

}